﻿using IterationLife.Datas;
using IterationLife.Educations.Models;
using IterationLife.Educations.Queries;
using IterationLife.Educations.Repositories;
using IterationLife.PlatformBackEnd.AppServices.Contracts.Educations;
using IterationLife.PlatformBackEnd.AppServices.Dtos.Educations;
using Util.Applications;
using Util.Datas.Queries;

namespace IterationLife.PlatformBackEnd.AppServices.Impl.Educations {
    /// <summary>
    /// 科目服务
    /// </summary>
    public class SubjectService : ApplicationServiceBase<Subject, SubjectDto, SubjectQuery>, ISubjectService {
        /// <summary>
        /// 初始化科目服务
        /// </summary>
        /// <param name="unitOfWork">工作单元</param>
        /// <param name="subjectRepository">科目仓储</param>
        public SubjectService( IApplicationUnitOfWork unitOfWork, ISubjectRepository subjectRepository )
            : base( unitOfWork, subjectRepository ) {
            SubjectRepository = subjectRepository;
        }
        
        /// <summary>
        /// 科目仓储
        /// </summary>
        protected ISubjectRepository SubjectRepository { get; set; }
        
        /// <summary>
        /// 转换为数据传输对象
        /// </summary>
        /// <param name="entity">实体</param>
        protected override SubjectDto ToDto( Subject entity ) {
            return entity.ToDto();
        }

        /// <summary>
        /// 转换为实体
        /// </summary>
        /// <param name="dto">数据传输对象</param>
        protected override Subject ToEntity( SubjectDto dto ) {
            return dto.ToEntity();
        }
        
        /// <summary>
        /// 创建查询对象
        /// </summary>
        /// <param name="param">科目查询实体</param>
        protected override IQueryBase<Subject> CreateQuery( SubjectQuery param ) {
            return new Query<Subject>( param );
        }
    }
}